<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="m" uri="/cutm_tags"%>
<html>
<head>
<title>设备管理-->设备外借申請</title>
<link rel="stylesheet" href="<s:url value="/common/css/datepicker.css"/>" type="text/css" />
<link rel="stylesheet" href="<s:url value="/common/css/nyroModal.css"/>" type="text/css" />
	<style type="text/css">
		#appUuserInfo{
		border: 0px;
		background-color: #DCE2F1"
		}
	</style>
<script type="text/javascript"
	src="<s:url value="/common/scripts/jquery.nyroModal-1.5.5.js"/>"></script>

<script type="text/javascript">
function getreturnInfo(){
	var flag = true;
	var str = "";
	$(".returnDevice").each(function(i){
		if($(this).attr('checked')){
			flag = false;
			var id = $(this).val();
			var fg = $('input[name='+id+'][checked = true]').val();
			var desc = $('input[name="desc'+id+'"]').val();
			str =str+id+":"+fg+":"+desc+";";
			}
		});
	if(flag){
		BaseJs.alert("请选择要归还的设备！！！");
		return false;
		}else{
			$("#rdid").val("").val(str);
			return  true;
		}
}
$(document).ready(function(){
	$("#editReturnDeviceForm").vaildAjax(function(data){
		BaseJs.alert(data);
		BaseJs.setReadonly();
		$("#returnds").hide("slow");
		});
	$("#clickAll").click(function(){
		if($(this).attr('checked')){
			$("input[name='retduid']").each(function(i){$(this).attr('checked',true);}); 
		  }else{
			  $("input[name='retduid']").each(function(i){$(this).attr('checked',false);}); 
			}
		});
	$("#returnds").click(function(){
		if(getreturnInfo()){
			$("#editReturnDeviceForm").submit();
			}
		
		});
	$("#query_button").click(function(){
		var userid = $("select[name='appUserId']").val();
		var appno = $("#appno").val();
		if(userid.length >0 || appno.length >0){
			$("#queryReturnDeviceForm").submit();
		}else{
			BaseJs.alert('请先选择输入查询条件！');
		}
	})
});
</script>
</head>
<body>
<h2 class="title">设备归还查询</h2>
	<s:form id="queryReturnDeviceForm" action="deviceuse/EditReturnDevice!toQuery">
		<table class="form">
			<tr>
				<th width="20%">设备申请人：</th>
				<td width="20%"><m:dropUser name="appUserId" headKey="--请选择--" headValue=""/></td>
				<th width="20%">设备申请号：</th>
				<td width="20%"><s:textfield name="appDeviceNo" id="appno"/></td>
				<td width="20%"><input type="button" value="查询" id="query_button"/> </td>
			</tr>		
		</table>
	</s:form>
<h2 class="title">设备归还入库</h2>
<s:form id="editReturnDeviceForm" action="deviceuse/EditReturnDevice!toReturn">
	<table class="form">
	<s:hidden name="appUserId" id="appuserid2" />
	<s:hidden name="appDeviceNo" id="appno"/>
		<tr>
			<th width="10%">设备领用时间：</th>
			<td width="20%"><s:date name="deviceuse.receiveDate" format='yyyy-MM-dd HH:mm'/></td>
			<th width="10%"><span class="hint">*</span>归还入库时间：</th>
			<td width="20%"><m:date name="deviceuse.real_enddate" cssClass="rule[required time]" time="true"/></td>
			<th width="10%">归还人：</th>
			<td  width="30%"><m:dropUser name="retUserId" headKey="--请选择--" headValue="" cssClass="rule[required]"/></td>
		</tr>
		<tr>
			<th width="10%">领取人：</th>
			<td  width="20%"><s:property value="deviceuse.userReceive.name" /> </td>
			<th width="10%">发放人：</th>
			<td  width="20%"><s:property value="deviceuse.userRelease.name" /> </td>
			<th width="10%">归还验收人：</th>
			<td  width="30%">
			<m:dropUser name="authUserId" headKey="--请选择--" headValue="" cssClass="rule[required]"/></td>
		</tr>
		<tr>
			<th width="10%">归还设备明细：</th>
			<td colspan="75"><s:hidden name="returnDeviceInfo" id="rdid"/>
				<table class="form">
					<thead>
						<tr>
							<th width="10%"><input type="checkbox" name="selectAll" id="clickAll"/>全选</th>
							<th width="10%">设备编号</th>
							<th width="15%">设备名称</th>
							<th width="10%">设备类别</th>
							<th width="13%">设备状态 </th>
							<th width="30%">设备故障说明</th>
						</tr>
					</thead>
					<tbody>
					<s:iterator value="dus">
						<tr id="pt${id }">
							<td><input type="checkbox" name="retduid" value="${deviceid.id }" class="returnDevice"/></td>
							<td><s:property value="deviceid.deviceNo" /></td>
							<td><s:property value="deviceid.deviceName" /></td>
							<td><m:property value="deviceid.devicetype" /></td>
							<td><input type="radio" name='${deviceid.id }' value="true" checked="checked"> 正常
								<input type="radio" name='${deviceid.id }' value="false"> 损坏
							</td>
							<td><input name="desc${deviceid.id }" type="text"/> </td>
						</tr>
				</s:iterator>
					</tbody>
				</table>
			</td>
		</tr>
		<tr>
			<th>设备延期归还说明：</th>
			<td colspan="5"><s:textarea name="deviceuse.delaydescribe"/></td>
		</tr>
	</table>
	<div class="btnGroup"><input type="button" value="确认归还" id="returnds"/> 
		<input type="button" value="返回列表" onclick="BaseJs.toAction('deviceuse/ListDeviceuse');" />
		</div>
</s:form>

</body>
</html>